package com.tongji.housediy.view
{
	import com.tongji.housediy.events.commonEvent.ShowHideControlPanelEvent;
	
	import org.robotlegs.mvcs.Mediator;
	
	import com.tongji.housediy.events.commonEvent.ShowHideControlPanelEvent;
	import com.tongji.housediy.model.RightCompStateModel;
	
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	import mx.core.FlexGlobals;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 * 
	 * @author chenchao
	 * 
	 */
	public class LeftUpMediator extends Mediator
	{
		[Inject]
		public var view:LeftUpComp;
		
		[Inject]
		public var model:RightCompStateModel;
		
		
		override public function onRegister():void
		{	
//			view.shortCutBg.addEventListener(Event.ADDED_TO_STAGE, shortCutBgAddedHandler);
//			
			this.addContextListener(ShowHideControlPanelEvent.SHOW_CONTROL_PANEL, showControlPanelHandler, ShowHideControlPanelEvent);
			this.addContextListener(ShowHideControlPanelEvent.HIDE_CONTROL_PANEL, hideControlPanelHandler, ShowHideControlPanelEvent);
//			
//			view.stage.addEventListener(Event.RESIZE, stageResizeHandler);
		}
		
//		private function shortCutBgAddedHandler(event:Event):void
//		{
//			view.shortCutBg.scale9Grid = new Rectangle(3, 3, 381, 23);
//			view.shortCutBg.scaleX = (view.stage.stageWidth - 344 - 275) / view.shortCutBg.width;
//		}
		
		private function showControlPanelHandler(event:ShowHideControlPanelEvent):void
		{
//			view.shortCutBg.scaleX = (view.stage.stageWidth - 344 - 275) / view.shortCutBg.width;
			view.currentState = "initial";
		}
		
		private function hideControlPanelHandler(event:ShowHideControlPanelEvent):void
		{
//			view.shortCutBg.scaleX = (view.stage.stageWidth - 344 - 10) / view.shortCutBg.width;
			view.currentState = "hide";
		}
		
		private function stageResizeHandler(event:Event):void
		{
//			switch (view.currentState)
//			{
//				case "initial":
//			view.shortCutBg.scaleX = (view.stage.stageWidth - 344 - 275) / view.shortCutBg.width;
//					break;
//				case "hide":
//					view.shortCutBg.scaleX = (view.stage.stageWidth - 344 - 10) / view.shortCutBg.width;
//					break;
//			}
		}
	}
}